package study.apache.thrift.helloworld;

import org.apache.thrift.TException;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;

public class Server {

	public static class HelloWorldHandler implements HelloWorld.Iface {

		@Override
		public void helloWorld() throws TException {
			System.out.println("hello world, hello thrift! ");
		}

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		HelloWorldHandler handler = new HelloWorldHandler();
		HelloWorld.Processor processor = new HelloWorld.Processor(handler);

		try {
			TServerTransport serverTransport;
			serverTransport = new TServerSocket(9090);
			TServer server = new TSimpleServer(

			new TServer.Args(serverTransport).processor(processor));

			server.serve();
		} catch (TTransportException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
